Whitespace (programming Language)
   HOME

TheInfoList



OR:

Whitespace is an
esoteric programming language An esoteric programming language (sometimes shortened to esolang) is a programming language designed to test the boundaries of computer programming language design, as a proof of concept, as software art, as a hacking interface to another language ...
developed by Edwin Brady and Chris Morris at the
University of Durham Durham University (legally the University of Durham) is a collegiate university, collegiate public university, public research university in Durham, England, Durham, England, founded by an Act of Parliament in 1832 and incorporated by royal charte ...
(also developers of the
Kaya Kaya may refer to: People *Kaya (given name) *Kaya (surname) Places *Kaya, Burkina Faso, a town in Burkina Faso, capital of the department *Kaya Airport, serving the town * Kaya Department, a department or commune of Sanmatenga Province in centr ...
and Idris programming languages). It was released on 1 April 2003 (
April Fool's Day April Fools' Day or All Fools' Day is an annual custom on 1 April consisting of practical jokes and hoaxes. Jokesters often expose their actions by shouting "April Fools!" at the recipient. Mass media can be involved in these pranks, which ma ...
). Its name is a reference to
whitespace character In computer programming, whitespace is any character or series of characters that represent horizontal or vertical space in typography. When rendered, a whitespace character does not correspond to a visible mark, but typically does occupy an area ...
s. Unlike most programming languages, which ignore or assign little meaning to most whitespace characters, the Whitespace interpreter ignores any non-whitespace characters. Only spaces, tabs and linefeeds have meaning. A consequence of this property is that a Whitespace program can easily be contained within the whitespace characters of a program written in a language which ignores whitespace, making the text a
polyglot Multilingualism is the use of more than one language, either by an individual speaker or by a group of speakers. It is believed that multilingual speakers outnumber monolingual speakers in the world's population. More than half of all Eu ...
. The
language Language is a structured system of communication. The structure of a language is its grammar and the free components are its vocabulary. Languages are the primary means by which humans communicate, and may be conveyed through a variety of ...
itself is an imperative stack-based language. The
virtual machine In computing, a virtual machine (VM) is the virtualization/ emulation of a computer system. Virtual machines are based on computer architectures and provide functionality of a physical computer. Their implementations may involve specialized h ...
on which the programs run has a stack and a heap. The programmer is free to push arbitrary-width integers onto the stack (currently there is no implementation of floating point numbers) and can also access the heap as a permanent store for variables and data structures.


History

Whitespace was created by Edwin Brady and Chris Morris in 2002.
Slashdot ''Slashdot'' (sometimes abbreviated as ''/.'') is a social news website that originally advertised itself as "News for Nerds. Stuff that Matters". It features news stories concerning science, technology, and politics that are submitted and eval ...
gave a review of this
programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming ...
on 1 April 2003. The idea of using whitespace characters as operators for the
C++ C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
language had been facetiously suggested five years earlier by
Bjarne Stroustrup Bjarne Stroustrup (; ; born 30 December 1950) is a Danish computer scientist, most notable for the invention and development of the C++ programming language. As of July 2022, Stroustrup is a professor of Computer Science at Columbia University ...
.


Syntax

Commands are composed of sequences of spaces, tab stops and linefeeds. All other characters are ignored and thus can be used for comments. For example, tab-space-space-space performs arithmetic addition of the top two elements on the stack. Code is written as an ''Instruction Modification Parameter'' (IMP) followed by the operation. The table below shows a list of all the IMPs in Whitespace. Each IMP is followed by one operation defined for that IMP, and a parameter if needed. The list of operations supported in Whitespace is: The "copy" and "slide" operations were added in Whitespace 0.3 and may not be supported by all implementations.


Numbers

Numbers are composed of spaces (0) and tabs (1), and they are terminated by a linefeed. The first space/tab in the number represents the sign of the number, if it's a space the number is positive, if it's a tab the number is negative. The rest of the trailing spaces and tabs represent the rest of the binary number.


Examples

space-tab-space-space-tab-space-tab-tab-linefeed (STSSTSTTL) represents the binary number 1001011 (positive, because the number starts with a space) => 75 in decimal. tab-tab-tab-space-space-tab-space-linefeed (TTTSSTSL) represents the binary number 110010 (negative, because the number starts with a tab) => -50 in decimal.


Labels

Labels are simply Fterminated lists of spaces and tabs. There is only one global namespace so all labels must be unique.


Sample code

The following is a commented Whitespace program that simply prints "Hello, world!", where each Space, Tab, or Linefeed character is preceded by the identifying comment "S", "T", or "L", respectively: S S S T S S T S S S L:Push_+1001000=72='H'_onto_the_stack T L S S :Output_'H';_S S S T T S S T S T L:Push_+1100101=101='e'_onto_the_stack T L S S :Output_'e';_S S S T T S T T S S L:+1101100=108='l' T L S S S S S T T S T T S S L:+1101100=108='l' T L S S S S S T T S T T T T L:+1101111=111='o' T L S S S S S T S T T S S L:+101100=44=',' T L S S S S S T S S S S S L:+100000=32=Space T L S S S S S T T T S T T T L:+1110111=119='w' T L S S S S S T T S T T T T L:+1101111=111='o' T L S S S S S T T T S S T S L:+1110010=114='r' T L S S S S S T T S T T S S L:+1101100=108='l' T L S S S S S T T S S T S S L=+1100100=100='d' T L S S S S S T S S S S T L:+100001=33='!' T L S S :Output_'!';_L L L:End_the_program Note that when Whitespace source code is displayed in some browsers, the horizontal spacing produced by a tab character is not fixed, but depends on its location in the text relative to the next horizontal tab stop. Depending on the software, tab characters may also get replaced by the corresponding variable number of space characters.


See also

*
Polyglot Multilingualism is the use of more than one language, either by an individual speaker or by a group of speakers. It is believed that multilingual speakers outnumber monolingual speakers in the world's population. More than half of all Eu ...
, a program valid in more than one language *
Steganography Steganography ( ) is the practice of representing information within another message or physical object, in such a manner that the presence of the information is not evident to human inspection. In computing/electronic contexts, a computer file, ...
, the technique of concealing a message within another message * Off-side rule languages, where blocks are expressed by whitespace indentation **
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
, the best-known example of a language with syntactically significant whitespace *
Esoteric programming language An esoteric programming language (sometimes shortened to esolang) is a programming language designed to test the boundaries of computer programming language design, as a proof of concept, as software art, as a hacking interface to another language ...
s **
Brainfuck Brainfuck is an esoteric programming language created in 1993 by Urban Müller. Notable for its extreme minimalism, the language consists of only eight simple commands, a data pointer and an instruction pointer. While it is fully Turing com ...
, which consists of only eight simple commands and an instruction pointer **
INTERCAL The Compiler Language With No Pronounceable Acronym (INTERCAL) is an esoteric programming language that was created as a parody by Don Woods and , two Princeton University students, in 1972. It satirizes aspects of the various programming langu ...
, the "Compiler Language With No Pronounceable Acronym" ** LOLCODE, which is patterned after a
series Series may refer to: People with the name * Caroline Series (born 1951), English mathematician, daughter of George Series * George Series (1920–1995), English physicist Arts, entertainment, and media Music * Series, the ordered sets used in ...
of Internet memes **
Malbolge Malbolge () is a public domain esoteric programming language invented by Ben Olmstead in 1998, named after the eighth circle of hell in Dante's ''Inferno'', the Malebolge. It was specifically designed to be almost impossible to use, via a counte ...
, which is specifically designed to be nearly impossible to program in


References


External links

*{{Official website, https://web.archive.org/web/20150618184706/http://compsoc.dur.ac.uk/whitespace/tutorial.php
Release announcement on SlashdotThe Whitespace Corpus
A collection of interpreters, compilers, and programs for Whitespace
Collection of Whitespace interpreters in various script languagesAcme::Bleach
A
Perl Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offic ...
module that rewrites the body of your module to a whitespace-only encoding ("for ''really'' clean programs"). Non-English-based programming languages Esoteric programming languages Whitespace Programming languages created in 2002 Stack-oriented programming languages